﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ApartmentSale
{
    public class AffirmanceView
    {
        public int affirmance_id { get; set; }
        public int affirmance_status { get; set; }
        public int receipt_id { get; set; }
        public string receipt_code { get; set; }
        public double affirmance_amount { get; set; }
        public string affirmance_rule_type { get; set; }
        public double affirmance_rule_rebate_amount { get; set; }
        public string affirmance_custom_name { get; set; }
        public string affirmance_custom_contact { get; set; }
        public DateTime affirmance_create_date { get; set; }

        public AffirmanceView()
        {
            affirmance_id = 0;
            affirmance_status = 0;
            receipt_id = 0;
            receipt_code = "";
            affirmance_amount = 0;
            affirmance_rule_type = "";
            affirmance_rule_rebate_amount = 0;
            affirmance_custom_name = "";
            affirmance_custom_contact = "";
            affirmance_create_date = DateTime.Now;
        }

        public string status_string
        {
            get
            {
                switch (affirmance_status)
                {
                    case 0:
                        return "Normal";
                    case 1:
                        return "Cancel out";
                    case 2:
                        return "Return";
                    case 3:
                        return "Invalid";
                }
                return "Unknown";
            }
        }

        public string date_string
        {
            get
            {
                return affirmance_create_date.ToShortDateString();
            }
        }

        public string rule_string
        {
            get
            {
                return "Type " + affirmance_rule_type + " Rebate:" +
                    String.Format("{0:N2}", affirmance_rule_rebate_amount);
            }
        }

        public override string ToString()
        {
            return receipt_code.Replace("''","'");
        }

        public void CopyTo(AffirmanceView another)
        {
            another.affirmance_id = affirmance_id;
            another.affirmance_status = affirmance_status;
            another.receipt_id = receipt_id;
            another.receipt_code = receipt_code;
            another.affirmance_amount = affirmance_amount;
            another.affirmance_rule_type = affirmance_rule_type;
            another.affirmance_rule_rebate_amount = affirmance_rule_rebate_amount;
            another.affirmance_custom_name = affirmance_custom_name;
            another.affirmance_custom_contact = affirmance_custom_contact;
            another.affirmance_create_date = affirmance_create_date;
        }
    }
}
